local sk__zuijiu = fk.CreateSkill {

  name = "sk__zuijiu",

  tags = {  },

}



sk__zuijiu:addEffect("active", {
  name = "sk__zuijiu",
  anim_type = "offensive",
  card_num = 0,
  target_num = 0,
  prompt = function (self,player)
    return "#sk__zuijiu:::"..(player:usedSkillTimes(sk__zuijiu.name, Player.HistoryPhase) + 1)
  end,
  can_use = function(self, player)
    return #table.filter(player:getCardIds("he"), function (id)
      return not player:prohibitDiscard(id)
    end) > player:usedSkillTimes(sk__zuijiu.name, Player.HistoryPhase)
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    math.randomseed(tonumber(tostring(os.time()):reverse():sub(1, 6)))
    local player = effect.from
    local cards = table.filter(player:getCardIds("he"), function (id)
      return not player:prohibitDiscard(id)
    end)
    cards = table.random(cards, player:usedSkillTimes(sk__zuijiu.name, Player.HistoryPhase))
    room:throwCard(cards, sk__zuijiu.name, player, player)
    if player.dead then return end
    local names = {}
    if not player:prohibitUse(Fk:cloneCard("analeptic")) then
      table.insert(names, "analeptic")
    end
    if not player:prohibitUse(Fk:cloneCard("slash")) and
      table.find(room:getOtherPlayers(player), function (p)
        return player:canUseTo(Fk:cloneCard("slash"), p, {bypass_times = true})
      end) then
      table.insert(names, "slash")
    end
    if #names == 0 then return end
    local name = table.random(names)
    if name == "analeptic" then
      room:useVirtualCard("analeptic", nil, player, player, sk__zuijiu.name, true)
    else
      local targets = table.filter(room:getOtherPlayers(player), function (p)
        return player:canUseTo(Fk:cloneCard("slash"), p, {bypass_times = true})
      end)
      room:useVirtualCard("slash", nil, player, table.random(targets), sk__zuijiu.name, true)
    end
  end,
})

return sk__zuijiu